package com.chenwut.arrayListDemo;

import java.util.ArrayList;

public class ArrayListDemo1 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();

        //添加元素
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");

        //删除元素
        /*boolean result1 = list.remove("aaa");
        System.out.println(result1);
        boolean result2 = list.remove("ddd");
        System.out.println(result2);
        String str = list.remove(2);
        System.out.println(str);*/

        //修改密码
        /*String str = list.set(1, "ddd");
        System.out.println(str);*/

        //查询
        /*String str = list.get(2);
        System.out.println(str);*/

        //遍历
        for (int i = 0; i < list.size(); i++) {
            String str = list.get(i);
            System.out.println(str);
        }

        System.out.println(list);
    }
}
